package com.bracketbird.server.jdo.club;

import com.bracketbird.client.model.*;
import com.bracketbird.client.model.tournament.*;
import com.bracketbird.server.dao.*;
import com.google.appengine.api.datastore.Key;

import javax.jdo.annotations.*;
import java.util.*;

/**
 *
 */
@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
public class RTCEventJDO extends JDO {


    @PrimaryKey
    @Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
    private Key key;

    //foreign key
    @Persistent
    private Key tournamentKey;

    @Persistent
    private Long id;

    private Long localId;

    @Persistent
    private Boolean deleted;

    //indicates what subtournament it is regarding. subtournament start = 0;
    @Persistent
    private Integer state;

    @Persistent
    private Integer eventType;

    @Persistent
    private String eventName;

    @Persistent
    private Date createdDate;

    @Persistent
    private Date lastChangeDate;

    //a reference to the tournamentVO, tournamentLevelVO, playingTeamVO or matchVO.
    @Persistent
    private Key modelKey;



    /*
     * All changeable data in tournament, tournamentlevel, match and playingteams are present below
     */

    //tournament
    @Persistent(serialized = "true", defaultFetchGroup = "true")
    private TournamentVO tournamentVO;

    //tournamentlevel
    @Persistent(serialized = "true", defaultFetchGroup = "true")
    private TournamentLevelVO tournamentLevelVO;

    //Tournament Level finished
    @Persistent(serialized = "true", defaultFetchGroup = "true")
    private LevelFinishedVO levelFinishedVO;


    //playingteam
    @Persistent(serialized = "true", defaultFetchGroup = "true")
    private PlayingTeamVO playingTeamVO;

    //Match
    @Persistent(serialized = "true", defaultFetchGroup = "true")
    private MatchVO matchVO;





    public RTCEventJDO() {

    }

    public Key getKey() {
        return key;
    }

    public void setKey(Key key) {
        this.key = key;
    }

    public Key getTournamentKey() {
        return tournamentKey;
    }

    public void setTournamentKey(Key tournamentKey) {
        this.tournamentKey = tournamentKey;
    }

    public Date getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Date createdDate) {
        this.createdDate = createdDate;
    }

    public Date getLastChangeDate() {
        return lastChangeDate;
    }

    public void setLastChangeDate(Date lastChangeDate) {
        this.lastChangeDate = lastChangeDate;
    }

    public Integer getState() {
        return state;
    }

    public void setState(Integer state) {
        this.state = state;
    }

    public Integer getEventType() {
        return eventType;
    }

    public void setEventType(Integer eventType) {
        this.eventType = eventType;
    }

    public Key getModelKey() {
        return modelKey;
    }

    public void setModelKey(Key modelKey) {
        this.modelKey = modelKey;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getEventName() {
        return eventName;
    }

    public void setEventName(String eventName) {
        this.eventName = eventName;
    }

    public TournamentVO getTournamentVO() {
        return tournamentVO;
    }

    public void setTournamentVO(TournamentVO tournamentVO) {
        this.tournamentVO = tournamentVO;
    }

    public TournamentLevelVO getTournamentLevelVO() {
        return tournamentLevelVO;
    }

    public void setTournamentLevelVO(TournamentLevelVO tournamentLevelVO) {
        this.tournamentLevelVO = tournamentLevelVO;
    }

    public PlayingTeamVO getPlayingTeamVO() {
        return playingTeamVO;
    }

    public void setPlayingTeamVO(PlayingTeamVO playingTeamVO) {
        this.playingTeamVO = playingTeamVO;
    }

    public MatchVO getMatchVO() {
        return matchVO;
    }

    public void setMatchVO(MatchVO matchVO) {
        this.matchVO = matchVO;

    }


    public LevelFinishedVO getLevelFinishedVO() {
        return levelFinishedVO;
    }

    public void setLevelFinishedVO(LevelFinishedVO levelFinishedVO) {
        this.levelFinishedVO = levelFinishedVO;
    }

    public Boolean getDeleted() {
        return deleted;
    }

    public void setDeleted(Boolean deleted) {
        this.deleted = deleted;
    }

    public Long getLocalId() {
        return localId;
    }

    public void setLocalId(Long localId) {
        this.localId = localId;
    }

    @Override
    public String toString() {
        return "RTCEventJDO{" +
                "key=" + key +
                ", tournamentKey=" + tournamentKey +
                ", id=" + id +
                ", state=" + state +
                ", eventType=" + eventType +
                ", eventName='" + eventName + '\'' +
                ", createdDate=" + createdDate +
                ", lastChangeDate=" + lastChangeDate +
                ", modelKey=" + modelKey +
                ", tournamentVO=" + tournamentVO +
                ", tournamentLevelVO=" + tournamentLevelVO +
                ", playingTeamVO=" + playingTeamVO +
                ", matchVO=" + matchVO +
                '}';
    }


}